﻿using System;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Tszy.Unlimited.Data.AdoNet.Sql.Components
{
    /// <summary>
    /// 数据清除器。
    /// </summary>
    /// <typeparam name="TSource">数据实体类型。</typeparam>
    public interface ICleaner<TSource>
    {
        /// <summary>
        /// 表达式上下文。
        /// </summary>
        public ExpressionContext Context { get; }

        /// <summary>
        /// 条件过滤。
        /// </summary>
        /// <param name="predicate">条件。</param>
        /// <returns>数据清除器。</returns>
        IWhereCleaner<TSource> Where(Expression<Func<TSource, bool>> predicate);
    }

    /// <summary>
    /// 数据清除器。
    /// </summary>
    /// <typeparam name="TSource">数据实体类型。</typeparam>
    public interface IWhereCleaner<TSource> : IExecuteCleaner<TSource>
    {
        /// <summary>
        /// 条件过滤。
        /// </summary>
        /// <param name="predicate">条件。</param>
        /// <returns>数据清除器。</returns>
        IWhereCleaner<TSource> Where(Expression<Func<TSource, bool>> predicate);
    }

    /// <summary>
    /// 删除处理器。
    /// </summary>
    /// <typeparam name="TSource">数据实体类型。</typeparam>
    public interface IExecuteCleaner<TSource>
    {
        /// <summary>
        /// 执行。
        /// </summary>
        /// <returns></returns>
        bool Execute();

        /// <summary>
        /// 执行。
        /// </summary>
        /// <returns></returns>
        Task<bool> ExecuteAsync();
    }
}